import React from 'react';
import Input from './DataCell/Input';
import Number from './DataCell/Number';
import Select from './DataCell/Select';
import Switch from './DataCell/Switch';
import Array from './DataCell/Array';
import Ref from './DataCell/Ref';

const DataCellMap = {
  text: Input,
  number: Number,
  enum: Select,
  bool: Switch,
  array: Array,
  ref: Ref,
};

export function getDataCell(item: any) {
  if (item.type && DataCellMap[item.type]) {
    const Comm: any = DataCellMap[item.type];
    return <Comm {...item} />;
  }
  return null;
}
